﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;

namespace Xiaov.SmartWeb.Application.HXZB.Tzfx
{
    public partial class TzzbIndex : Xiaov.SmartWeb.Model.BasePage
    {
        protected string nf = DateTime.Now.Year.ToString();
        protected string yf = (DateTime.Now.Month - 1).ToString();
        protected string dwbm = "HB";
        protected double htje = 0;//合同金额累计
        protected double bnljsjtz = 0;//本年完成投资累计
        protected double bnljjhtz = 0;//本年累计计划投资
        protected double bnjhwcl = 0;//本年累计计划完成率
        protected string xmlbid = "T1";
        protected string xmmc = "";   

        protected void Page_Load(object sender, EventArgs e)
        {
            PM_Filter_Statistical();
            if (!Page.IsPostBack)
            {               
                BindDDL();             
            }
            if ((Session["yf"] != null) && (Session["nf"] != null))
            {
                nf = Session["yf"].ToString();
                yf = Session["nf"].ToString();
            }
            if (Request.QueryString["nf"] != null && Request.QueryString["yf"] != null)
            {
                nf = Request.QueryString["nf"].ToString();
                yf = Request.QueryString["yf"].ToString();
            }
            if (Request.QueryString["xmlbid"] != null)
            {
                xmlbid = Request.QueryString["xmlbid"];
            }
            if (Request.QueryString["xmmc"] != null)
            {
                xmmc = Request.QueryString["xmmc"];
            }
           

            #region 文字部分使用
            string sSql = @"select htje,bnljsjtz,bnljjhtz from v_cj_yt_tzzb where pxbm ='T1' and nf =" + nf + " and yf =" + yf;
            OracleDataReader dr = (OracleDataReader)Maticsoft.DBUtility.DbHelperOra.ExecuteReader(sSql);
            while (dr.Read())
            {
                if (dr["htje"] != DBNull.Value)
                {
                    htje = Convert.ToDouble(dr["htje"]);
                }
                if (dr["bnljsjtz"] != DBNull.Value)
                {
                    bnljsjtz = Convert.ToDouble(dr["bnljsjtz"]);
                }
                if (dr["bnljjhtz"] != DBNull.Value)
                {
                    bnljjhtz = Convert.ToDouble(dr["bnljjhtz"]);
                    bnjhwcl = bnljsjtz / bnljjhtz * 100;
                }
            }
            dr.Close();
            #endregion
        }

        protected void BindDDL()
        {
            try
            {
                Statistics.UI.DDL.BindDDL(ddl_Owner, ddl_Year, ddl_Month, PUser.USERDEPT, true);
            }
            catch (Exception ex)
            {

            }
            //从cookies获取默认值
            if (Request.Cookies["UserSelectInfo"] != null)
            {
                ddl_Owner.SelectedValue = Request.Cookies["UserSelectInfo"]["DW"];
                ddl_Year.SelectedValue = Request.Cookies["UserSelectInfo"]["NF"];
                ddl_Month.SelectedValue = Request.Cookies["UserSelectInfo"]["YF"];
            }
            if ((Session["yf"] != null) && (Session["nf"] != null))
            {
                ddl_Month.SelectedValue = Session["yf"].ToString();
                ddl_Year.SelectedValue = Session["nf"].ToString();
            }
            nf = ddl_Year.SelectedValue;
            yf = ddl_Month.SelectedValue;
            dwbm = ddl_Owner.SelectedValue;
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            Session["nf"] = ddl_Year.SelectedValue;
            Session["yf"] = ddl_Month.SelectedValue;
            nf = ddl_Year.SelectedValue;
            yf = ddl_Month.SelectedValue;
            dwbm = ddl_Owner.SelectedValue;

            string js = "window.location.href='TzzbIndex.aspx?sfXmlb=True&nf=" + nf + "&yf=" + yf + "&dw=" + dwbm + "&xmlbid=" + xmlbid + "'";
            Response.Write("<script type='text/javascript' language='javascript'>" + js + "</script>");
        }
    }
}